package com.cyufeng.blog.service.mapper;

import com.cyufeng.blog.dto.MoodDto;
import com.cyufeng.blog.dto.MoodDto;
import com.cyufeng.blog.entity.Mood;

import java.util.ArrayList;
import java.util.List;
/**
 * 心情
 * @author Cyufeng
 * Data:2018.12.30
 */
public class MoodMapper {
    public MoodDto entityTodto(Mood mood){
        MoodDto moodDto = new MoodDto();
        moodDto.setId(mood.getId());
        moodDto.setAuthor(mood.getAuthor());
        moodDto.setDetail(mood.getDetail());
        moodDto.setDr(mood.getDr());
        moodDto.setMadeTime(mood.getMadeTime());
        moodDto.setDelTime(mood.getDelTime());
        return moodDto;
    }
    public Mood dtoToentity(MoodDto moodDto){
        Mood mood = new Mood();
        mood.setId(moodDto.getId());
        mood.setAuthor(moodDto.getAuthor());
        mood.setDetail(moodDto.getDetail());
        mood.setDr(moodDto.getDr());
        mood.setMadeTime(moodDto.getMadeTime());
        mood.setDelTime(moodDto.getDelTime());
        return mood;
    }
    //list集合
    public List<MoodDto> entityTodto(List<Mood> moodList){
        List<MoodDto> moodDtoList = new ArrayList<>();
        for (int i = 0;i<moodList.size();i++){
            Mood mood = moodList.get(i);
            MoodDto moodDto = new MoodDto();
            moodDto.setId(mood.getId());
            moodDto.setAuthor(mood.getAuthor());
            moodDto.setDetail(mood.getDetail());
            moodDto.setDr(mood.getDr());
            moodDto.setMadeTime(mood.getMadeTime());
            moodDto.setDelTime(mood.getDelTime());
            moodDtoList.add(moodDto);
        }

        return moodDtoList;
    }
    public List<Mood> dtoToentity(List<MoodDto> moodDtoList){
        List<Mood> sortList = new ArrayList<>();
        for (int i = 0;i<moodDtoList.size();i++) {
            Mood mood = new Mood();
            MoodDto moodDto = moodDtoList.get(i);
            mood.setId(moodDto.getId());
            mood.setAuthor(moodDto.getAuthor());
            mood.setDetail(moodDto.getDetail());
            mood.setDr(moodDto.getDr());
            mood.setMadeTime(moodDto.getMadeTime());
            mood.setDelTime(moodDto.getDelTime());
            sortList.add(mood);
        }
        return sortList;
    }
}
